﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using IDAL.RF.Repair;
using Model.RF.Repair;

namespace DAL.RF.Repair
{
    public class RepairRoute : BaseRepository<RepairRouteInfo>, IRepairRoute
    {
        #region 静态变量定义部分
        private const string PARM_ID = "@ID";
        private const string PARM_STEPITEM = "@StepItem";
        #endregion
        
        #region 检索部分
        public IList<RepairRouteInfo> LoadEntities()
        {
            return ExcuteSqlToGetEntities("RepairRoute_select");
        }

        public RepairRouteInfo LoadEntity<T1>(T1 id)
        {
            SqlParameter parm=GetParameter();
            return ExcuteSqlToGetEntity("RepairRoute_selectbyID", parm);
        }

        public IList<RepairRouteInfo> RepairRoute_GetbyStepItem(string stepItem)
        {
            SqlParameter Parm = new SqlParameter(PARM_STEPITEM, SqlDbType.NVarChar, 20);
            Parm.Value = stepItem;
            return ExcuteSqlToGetEntities("RepairRoute_selectbyStepItem", Parm);
        }
        #endregion

        #region 重写基类部分
        public override RepairRouteInfo GetEntityRecord(SqlDataReader rdr)
        {
            RepairRouteInfo pro = new RepairRouteInfo()
            {
                ID = rdr.GetInt32(0), 
                StepItem= rdr.GetValue(1).ToString(), 
                RepairPath= rdr.GetValue(2).ToString() 
            };
            return pro;
        }

        public override RepairRouteInfo GetEntityRecord()
        {
            RepairRouteInfo pro = new RepairRouteInfo();
            return pro;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_ID, SqlDbType.Int, 4);
            return Parm;
        }
        #endregion
    }
}
